package nnweboa;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SystemConfig {
	private static SystemConfig scf = null;
	private static Connection conn = null;
	private String url;

	private SystemConfig() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {

		Class.forName("com.mysql.jdbc.Driver").newInstance();
		url = "jdbc:mysql://localhost:3306/weboa";
		conn = DriverManager.getConnection(url, "root", "38574638");

	}

	public static SystemConfig getInstance() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
		if (scf == null) {
			scf = new SystemConfig();
		}
		return scf;
	}

	public Connection getConnection() throws SQLException {
		if (conn.isClosed()) {
			conn = DriverManager.getConnection(url, "root", "38574638");
		}
		return conn;
	}

}
